let str = 'abc345efg'
let a = str.match(/\d/g)
console.log(a)
for (let i = 0; i < a.length; i++) {
    str = str.replace(a[i], '[' + a[i] + ']')
}
alert(str)